﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

// Reviewed

#pragma once
#include "GcmpGeometryInterface.h"
#include "IArc2d.h"
#include "ICurve2d.h"

namespace gcmp
{
    class Vector2d;

    enum class EnFillet2dErrorType : int32_t
    {
        FET_Failed = -1,           ///<倒圆角失败
        FET_Success = 0,           ///<倒圆角成功
        FET_SuccessButParallel,    ///<倒圆角成功,但提供警告,输入为平行直线或同心圆
        FET_InvalidInput,          ///<非法输入：空曲线,半径超出允许范围,曲线太短,参考点不在曲线上
        FET_UnsupportedCurveType,  ///<不支持的曲线类型
        FET_BadRadius,             ///<半径太大或太小,无法计算圆角
        FET_BadRefPoint,           ///<参考点无法确定圆角位置
        FET_NoSuitableArc          ///<没有合适半径的圆
    };

    /// \brief  二维曲线倒圆角结果结构体
    struct GCMP_GEOMETRY_INTERFACE_EXPORT Fillet2dResult
    {
        /// 圆角
        OwnerPtr<IArc2d> opArc = nullptr;
        /// 第一条曲线延伸或裁剪后的曲线
        OwnerPtr<ICurve2d> opResultCurve1 = nullptr;
        /// 第二条曲线延伸或裁剪后的曲线
        OwnerPtr<ICurve2d> opResultCurve2 = nullptr;
    };

    class IFillet2d
    {
    public:
        virtual ~IFillet2d() {}

        /// \brief 二维曲线倒圆角接口
        /// \param[in] pCurve1 输入曲线1
        /// \param[in] pCurve2 输入曲线2
        /// \param[in] referencePoint1 曲线1上参考点1
        /// \param[in] referencePoint2 曲线2上参考点2
        /// \param[in] radius 用户输入半径
        /// \param[in,out] result 倒圆角结果结构体
        /// \return EnFillet2dErrorType 倒圆角结果类型
        virtual gcmp::EnFillet2dErrorType Fillet2dCurves(const gcmp::ICurve2d *pCurve1, const gcmp::ICurve2d *pCurve2
            , gcmp::Vector2d referencePoint1, gcmp::Vector2d referencePoint2, double dRadius, gcmp::Fillet2dResult &result) const = 0;
        
    };
}
